package org.easy.http.client.util.json.gson;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import org.easy.http.client.util.ArrayUtils;

/**
 * @Description TODO
 * @Author WuXueLi
 * @Date 18:17 2023/2/4
 * @Version 1.0
 **/
public class PropertyNameExclusionStrategy implements ExclusionStrategy {

    private final String[] ignorePropertyNames;

    PropertyNameExclusionStrategy(String[] ignorePropertyNames) {
        this.ignorePropertyNames = ignorePropertyNames;
    }

    /**
     * @param fieldAttributes the field object that is under test
     * @return true if the field should be ignored; otherwise false
     */
    @Override
    public boolean shouldSkipField(FieldAttributes fieldAttributes) {
        return this.ignorePropertyNames != null && ArrayUtils.containsElement(ignorePropertyNames, fieldAttributes.getName());
    }

    /**
     * @param clazz the class object that is under test
     * @return true if the class should be ignored; otherwise false
     */
    @Override
    public boolean shouldSkipClass(Class<?> clazz) {
        return false;
    }



}
